package com.tanhua.server.service;

import com.tanhua.dubbo.api.UserApi;
import com.tanhua.model.domain.User;
import com.tanhua.model.vo.HuanXinUserVo;
import com.tanhua.server.interceptor.UserHolder;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

@Service
public class HuanXinService {

    @DubboReference
    private UserApi userApi;

    /*查询环信用户信息*/
    public HuanXinUserVo findHuanXinUser() {
        //获取当前用户id
        Long userId = UserHolder.getUserId();
        //查询当前用户信息
        User user=userApi.findById(userId);
        //判断user对象是否存在
        if(user == null) {
            return null;
        }
        //构造vo对象并返回
        HuanXinUserVo vo=new HuanXinUserVo();
        vo.setUsername(user.getHxUser());
        vo.setPassword(user.getHxPassword());
        return vo;
    }
}
